home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 1.5)
-
- '''Test script for the imageop module. This has the side
- effect of partially testing the imgfile module as well.
- Roger E. Masse
- '''
- unlink
- import imageop
- import uu
-
- def main(use_rgbimg = 1):
- uu.decode(get_qualified_path('testrgb.uue'), 'test.rgb')
- if use_rgbimg:
- (image, width, height) = getrgbimage('test.rgb')
- else:
- (image, width, height) = getimage('test.rgb')
- if verbose:
- print 'crop'
-
- newimage = imageop.crop(image, 4, width, height, 0, 0, 1, 1)
- if verbose:
- print 'scale'
-
- scaleimage = imageop.scale(image, 4, width, height, 1, 1)
- if verbose:
- print 'tovideo'
-
- videoimage = imageop.tovideo(image, 4, width, height)
- if verbose:
- print 'rgb2rgb8'
-
- greyimage = imageop.rgb2rgb8(image, width, height)
- if verbose:
- print 'rgb82rgb'
-
- image = imageop.rgb82rgb(greyimage, width, height)
- if verbose:
- print 'rgb2grey'
-
- greyimage = imageop.rgb2grey(image, width, height)
- if verbose:
- print 'grey2rgb'
-
- image = imageop.grey2rgb(greyimage, width, height)
- if verbose:
- print 'grey2mono'
-
- monoimage = imageop.grey2mono(greyimage, width, height, 0)
- if verbose:
- print 'mono2grey'
-
- greyimage = imageop.mono2grey(monoimage, width, height, 0, 255)
- if verbose:
- print 'dither2mono'
-
- monoimage = imageop.dither2mono(greyimage, width, height)
- if verbose:
- print 'grey2grey4'
-
- grey4image = imageop.grey2grey4(greyimage, width, height)
- if verbose:
- print 'grey2grey2'
-
- grey2image = imageop.grey2grey2(greyimage, width, height)
- if verbose:
- print 'dither2grey2'
-
- grey2image = imageop.dither2grey2(greyimage, width, height)
- if verbose:
- print 'grey42grey'
-
- greyimage = imageop.grey42grey(grey4image, width, height)
- if verbose:
- print 'grey22grey'
-
- image = imageop.grey22grey(grey2image, width, height)
- unlink('test.rgb')
-
-
- def getrgbimage(name):
- """return a tuple consisting of image (in 'imgfile' format but
- using rgbimg instead) width and height"""
- import rgbimg
-
- try:
- sizes = rgbimg.sizeofimage(name)
- except rgbimg.error:
- name = get_qualified_path(name)
- sizes = rgbimg.sizeofimage(name)
-
- if verbose:
- print 'rgbimg opening test image: %s, sizes: %s' % (name, str(sizes))
-
- image = rgbimg.longimagedata(name)
- return (image, sizes[0], sizes[1])
-
-
- def getimage(name):
- """return a tuple consisting of
- image (in 'imgfile' format) width and height
- """
- import imgfile
-
- try:
- sizes = imgfile.getsizes(name)
- except imgfile.error:
- name = get_qualified_path(name)
- sizes = imgfile.getsizes(name)
-
- if verbose:
- print 'imgfile opening test image: %s, sizes: %s' % (name, str(sizes))
-
- image = imgfile.read(name)
- return (image, sizes[0], sizes[1])
-
-
- def get_qualified_path(name):
- ''' return a more qualified path to name'''
- import sys
- import os
- path = sys.path
-
- try:
- path = [
- os.path.dirname(__file__)] + path
- except NameError:
- pass
-
- for dir in path:
- fullname = os.path.join(dir, name)
-
- return name
-
- main(use_rgbimg = 1)
-